home *** CD-ROM | disk | FTP | other *** search
- Path: theory.lcs.mit.edu!wald
- From: wald@theory.lcs.mit.edu (David Wald)
- Newsgroups: comp.lang.ada,comp.lang.c++,comp.lang.c,comp.lang.modula3,comp.lang.modula2,comp.lang.eiffel
- Subject: Re: type checking in C++ was Re: Hungarian notation
- Followup-To: comp.lang.c++
- Date: 11 Jan 1996 15:35:16 GMT
- Organization: Theory of Computation, LCS, MIT
- Message-ID: <WALD.96Jan11103517@woodpecker.lcs.mit.edu>
- References: <4cf8hf$8fe@hopi.gate.net> <DKoBrn.CHs@falcon.daytonoh.attgis.com>
- <4d1j37$ge8@stc06.ctd.ornl.gov> <4d2dqq$4lq@news.uni-c.dk>
- NNTP-Posting-Host: woodpecker.lcs.mit.edu
- In-reply-to: Peter Juhl's message of 11 Jan 1996 07:22:02 GMT
-
- In article <4d2dqq$4lq@news.uni-c.dk> Peter Juhl
- <etiaseti@inet.uni-c.dk> writes:
- >mbk@jt3ws1.etd.ornl.gov (Kennel) wrote:
- >>Dick Menninger (Dick.Menninger@DaytonOH.ATTGIS.COM) wrote:
- >>> Imbedding type information in a name had some utility
- >>> in the older C environments with the weak type checking
-
- >>At one point something like this could be a problem. It it still?
- >>
- >>function(Type *p) {
- >>
- >>// One of this may silently crash or do bad things. Both typecheck.
- >>
- >>// delete p;
- >>// delete [] p;
- >>
- >>}
- >>
-
- >This has not been a problem for years, delete p , is the way
- >things work.
-
- If you're talking about C++, you're mistaken; you don't know from the
- type of p whether *p was allocated with new or new[], and you get
- undefined behavior if you use the wrong delete. You may be thinking
- of the numeric argument to delete[], as in "delete[5] p", which is
- indeed obsolete, but the delete vs. delete[] problem still exists.
-
- This is described briefly in questions 37 & 38 of the comp.lang.c++
- Frequently Asked Questions list, and at greater length in sections
- [expr.new] and [expr.delete] of the draft ANSI standard.
-
- -David
- --
- ============================================================================
- David Wald http://theory.lcs.mit.edu/~wald/ wald@theory.lcs.mit.edu
- ============================================================================
-